I tried creating a calculator lambda function by integrating AWS API Gateway and Lambda

I tried creating a calculator lambda function by integrating AWS API Gateway and Lambda

Clock Icon2023.05.18

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

Introduction

Hemanth of Alliance Department here. In this blog, I tried creating a calculator lambda function by integrating AWS API Gateway and Lambda.

AWS Lambda

A serverless compute service that runs code as a reply to events and automatically takes care of the bottom resources. It runs code on high availability compute infrastructure and performs all the administration of the compute resources. A few examples are HTTP requests vis Amazon API Gateway, changes to objects in S3, and many others.

API Gateway

A fully managed service that makes developers easily create, publish, maintain, monitor, and secure APIs at any scale. Using API Gateway can create Restful APIs and WebSocket APIs which have real-time two-way communication applications. It is a front door for applications to access data, business logic, or functionality from your backend services.

Demo

Go to Lambda and click on create function Give a function name, keep other settings as default and click on create function Make the following changes in the code Configuring a test event Now deploy the lambda Now testing it The numbers get added up and it's working as expected Now open the API gateway and click on build RestAPI click on new api, give an API name and click on create API Now click on slash next actions and then resource Make following changes and click on resource select name, actions and select create method select get and make the following changes select the integration request Make the following change and click save Now deploying the API Select new stage and click deploy select the root, click action and select create resource give a resource name and click create resource select the above created resource and click on create resource
Make following changes and click on create method Now creating method of type POST for the above resource, selecting the created lambda function and click save click on integration request if you scroll down then you can create a mapping template now start creating a mapping template Making the following changes in the mapping templates and click save Now testing it After clicking on test, we get output as expected

Conclusion

Hope with this you get an idea of how to create a calculator lambda function by integrating AWS API Gateway and Lambda. Thank you for seeing the blog till the end.

Share this article

facebook logohatena logotwitter logo

© Classmethod, Inc. All rights reserved.